﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x0200004F RID: 79
	public class NullableCharFormatter : IMessagePackFormatter<char?>
	{
		// Token: 0x0600012B RID: 299 RVA: 0x00004CD8 File Offset: 0x000030D8
		private NullableCharFormatter()
		{
		}

		// Token: 0x0600012C RID: 300 RVA: 0x00004CE0 File Offset: 0x000030E0
		public int Serialize(ref byte[] bytes, int offset, char? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteChar(ref bytes, offset, value.Value);
		}

		// Token: 0x0600012D RID: 301 RVA: 0x00004D08 File Offset: 0x00003108
		public char? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new char?(MessagePackBinary.ReadChar(bytes, offset, out readSize));
		}

		// Token: 0x04000043 RID: 67
		public static readonly NullableCharFormatter Instance = new NullableCharFormatter();
	}
}
